package top.kaoshanji.r5ch12e;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/11 11:18
 */
@Service("userService")
public class UserService {

    private void method1() {
        System.out.println("in method1");
    }

    public final void method2() {
        System.out.println("in method2");
    }

    public static void method3() {
        System.out.println("in method3");
    }

    public void method4() {
        System.out.println("in method4");
    }

    public final void method5() {
        System.out.println("in method5");
        // method4();
    }

    protected void method6(){
        System.out.println("in method6");
    }


    // 代码清单-r5ch12e-414页a：事务增强遗漏实例
    public static void main(String[] args) {

        ApplicationContext context = new ClassPathXmlApplicationContext("r5ch12e/application-context.xml");

        UserService userService = (UserService)context.getBean("userService");

        System.out.println("...执行method1方法之前...");
        userService.method1();
        System.out.println("...执行method1方法之后...");

        System.out.println("...执行method2方法之前...");
        userService.method2();
        System.out.println("...执行method2方法之后...");

        System.out.println("...执行method3方法之前...");
        userService.method3();
        System.out.println("...执行method3方法之后...");

        System.out.println("...执行method4方法之前...");
        userService.method4();
        System.out.println("...执行method4方法之后...");

        System.out.println("...执行method5方法之前...");
        userService.method5();
        System.out.println("...执行method5方法之后...");

        System.out.println("...执行method6方法之前...");
        userService.method6();
        System.out.println("...执行method6方法之后...");


    }


}
